<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="pub/top_list2.jsp"%> 
<% 
String userid = (String) request.getSession().getAttribute("name");
String allprice=(String)request.getParameter("allprice");
String id=(String)request.getParameter("id");
//System.out.println(id);
 String productid = (String) request.getParameter("productid");
 String[] params = new String[1];
 params[0] =userid;
 String sql = "select a.sximg,b.oprice,a.sxname,c.classify,d.*,d.count*b.oprice as tprice,e.* from goodsx a, goodjiage b,shuxing c,shopping d,goodinfo e where a.goodsxid=b.goodsxid and e.productid=a.productid and a.goodsxid=d.goodsxid and a.sxid=c.sxid and  a.goodsxid  in (select goodsxid from shopping where userid=? and count>0)";
 List<Map<String, Object>> list= db.queryList(sql, params);
 
 MyDB db2 = My.getDb1();
 String[] param = new String[1];
 param[0] =userid;
 String sql2="select * from manageadd where userid=? and state=1";
 Map<String, Object> mp= db2.queryMap(sql2, param);
/*  BigDecimal yf=new BigDecimal("0");
 for(int i=0;i<list.size();i++){
	 Map map = (Map)list.get(i);
	 BigDecimal yunfei=new BigDecimal(map.get("yunfei").toString());
	 yf=yf.add(yunfei);
 }
 System.out.print(yf); */
 %>

<body>
	<header class="top-header fixed-header">
			<a class="icona" href="javascript:history.go(-1)">
					<img src="images/left.png"/>
			</a>
			<h3>去结算</h3>
			<!-- <a class="iconb" href="shopcar.html">
			</a> -->
	</header>
	
	<div class="contaniner fixed-cont">
		<section class="to-buy">
			<header>
				<div class="now">
					<span><img src="images/map-icon.png"/></span>
						<dl>
							<dt>
								<b><%=mp.get("username") %></b>
								<strong><%=userid %></strong>
							</dt>
							<dd><%=mp.get("province") %><%=mp.get("city") %><%=mp.get("distric") %><%=mp.get("address") %></dd>
							<p>其他地址</p>
						</dl> 
				</div>
				
				<div class="to-now">
					<div class="tonow">
						<!-- 	<label for="tonow"  onselectstart="return false" ></label>
							<input type="checkbox" id="tonow"/> -->
					</div>
					<dl>
							<dt>
								<b><%=mp.get("username") %></b>
								<strong><%=userid %></strong>
							</dt>
							<dd><%=mp.get("province") %><%=mp.get("city") %><%=mp.get("distric") %><%=mp.get("address") %></dd>
					</dl>
					<h3><a href="go-address.html"><img src="images/write.png"/></a></h3>
				</div>
			</header>
			
			<div class="buy-list"> <%
	          String shopmxid="";
	          String oprice="";
			    for (int i=0;i<list.size();i++) {
				Map m = (Map)list.get(i);
				String sximg = m.get("sximg").toString();
				String classify=m.get("classify").toString();
				String sxname=m.get("sxname").toString();
			    oprice=m.get("oprice").toString();
				shopmxid=m.get("shopmxid").toString();
				String count=m.get("count").toString();
				String tpirce=m.get("tprice").toString();
				String yunfei=m.get("yunfei").toString();
		    %>
			
				<ul>
					<a href="detail.html">
						<figure>
							<img src="<%=sximg %>"/>
						</figure>
						<li>
							<h3>超级大品牌服装，现在够买只要998</h3>
							<span>
								<%=classify %>：<%=sxname %>
								<br />
							</span>
							<b>￥<%=oprice %></b>
							<small>×<%=count %></small>
						</li>
					</a>
				</ul>
				<dl>
					<%-- <dd>
						<span>运费</span>
						<small><%=yunfei %></small>
					</dd> --%>
					<dd>
						<span>商品总额</span>
						<small>￥<%=tpirce %></small>
					</dd>
					<%} %>
					<dt>
						<textarea rows="4" id="liuyan" value="" placeholder="给卖家留言（50字以内）"></textarea>
					</dt>
				</dl>
			</div>
			
		</section>
		<!--底部不够-->
		<div style="margin-bottom: 9%;"></div>
	</div>
	
	<footer class="buy-footer fixed-footer">
			<p> 
				<small>运费</small>
				<b>暂无&nbsp;&nbsp;</b>
				<small>总金额</small>
				<b><%=allprice %></b>
			</p>
			
				
				<input type="button" onclick="fukuan()" value="去付款"/>
	</footer>
	<script type="text/javascript">
	function fukuan(){
		var liuyan=document.getElementById("liuyan").value;
		var allprice='<%=allprice%>';
		var id='<%=id%>';
		var dz='<%=mp.get("id")%>'
		window.location.href="fukun.jsp?liuyan="+liuyan+"&allprice="+allprice+"&id="+id+"&dz="+dz;
	}                         
	</script>
	<script type="text/javascript">
		$(".to-now .tonow label").on('touchstart',function(){
			if($(this).hasClass('ton')){
				$(".to-now .tonow label").removeClass("ton")
			}else{
				$(".to-now .tonow label").addClass("ton")
			}
		})
	</script>

</body>
</html>